Skip to content

feat(sandbox): add quarantined patch validation - #65

Open
seonghobae wants to merge 136 commits into
mainfrom
feat/quarantined-patch-validation
Open

feat(sandbox): add quarantined patch validation#65
seonghobae wants to merge 136 commits into
mainfrom
feat/quarantined-patch-validation

Conversation

@seonghobae

@seonghobae seonghobae commented Aug 5, 2026

Copy link
Copy Markdown
Contributor

Summary

Adds a credential-free, allowlisted patch-validation boundary for exact-head review evidence. Untrusted source, patch content, repository scripts, Git status and exact-tree output, archive metadata, extracted filesystem objects, and validator output remain outside GitHub App, reviewer-model, NVIDIA NIM, Cloudflare, OIDC, publication, deployment, and Docker-socket credentials.

Buyer-visible gap addressed

Noema could quarantine source for graph inspection but lacked a bounded contract for validating a proposed patch against an authenticated exact Git revision without crossing a credential boundary. This PR supplies that evidence plane while preserving separation among check runs, commit statuses, review evidence, model judgement, protected-branch approval, build provenance, release acceptance, and deployment authority.

Implemented boundary

  • exact repository/base/head/patch-SHA-256/profile request and result binding;
  • enum-only validation profiles with no caller-provided shell command;
  • immutable digest-pinned validator image reference and --pull=never;
  • strict UTF-8 patch preflight for binary payloads, symlink/gitlink modes, noncanonical aliases, traversal, absolute/control-character/raw-backslash paths, malformed quoting, duplicate/oversized file sets, independent file/rename/copy metadata families, exact path-role binding, hunk counts, and governance-sensitive paths;
  • descriptor-safe, no-follow patch, Git control-file, extracted-blob, and result reads with inode/device stability and distinct byte limits;
  • configuration-isolated exact Git HEAD and clean-worktree verification covering tracked, staged, untracked, and ignored drift;
  • constant-space dirty-worktree detection and byte/record-bounded Git output streaming with early termination;
  • source-local filesystem and HTTP alternate object databases rejected fail-closed;
  • retained immutable exact-tree inventory containing canonical path, Git mode, object ID, and size;
  • bounded exact-commit archive materialization with safe member allowlisting;
  • archive regular-file path, mode, and size equality against the authenticated exact-tree inventory;
  • descriptor-safe Git blob rehashing using blob <size>\0<bytes> with SHA-1/SHA-256 identity verification before Docker starts;
  • private source snapshot and patch staging, no-network/read-only/non-root Docker isolation, one bounded result-file mount, and no Docker socket;
  • beginner-readable public docstrings, authoritative documentation, CHANGELOG.md, and APA 7th standards doctoring.

Exact-head acceptance evidence

Current exact head: 5c2e6762d07598094e5301c491d15ba83dcdcd51

  • ci run 31083752256: success
  • Security Scan run 31083752101: success
  • reviewer-ci run 31083751990: success
  • reviewer suite: 370 passed
  • production coverage: 1,497 statements and 492 branches at 100%
  • public docstring coverage: 100%
  • signed distroless CodeGraph sandbox image verification and configured vulnerability gate: success
  • all inline review threads are resolved; historical repair-workflow findings are outdated because those invalid workflows were removed
  • the exact-head P2 documentation finding was addressed in the public contract, APA 7th doctoring, and CHANGELOG.md
  • CodeRabbit completed a read-only review of base 9adb784902cae19a150146a8fadd6a0491f67814 and exact head 5c2e6762d07598094e5301c491d15ba83dcdcd51, confirmed the head remained unchanged, and reported no actionable current-head issue in the requested scope
  • the separate CodeRabbit commit status is retained as status evidence only; neither the status nor the review comment is a GitHub APPROVE

Review and merge state

  • No eligible independent GitHub APPROVE currently exists.
  • A formal review request for opencode-agent and cwl-noema-review was rejected with HTTP 422 because one or both identities are not repository collaborators; mentions and model comments do not substitute for approval. Operational provisioning remains tracked by chore(operations): provision and activate hourly maintainer App #29.
  • Issue chore(governance): protect main and enforce release checks #27 remains open because main still lacks acceptance evidence for an enforceable ruleset, current-head required checks and approval, direct-push rejection, and reviewed break-glass controls.
  • Immediate merge and auto-merge remain prohibited.

Scope boundary

This PR adds a library and evidence contract. It does not yet publish or activate the dedicated patch-validator image in the reviewer decision flow. Image build, signature, SBOM, provenance, scan, runtime verification, and activation remain tracked separately by #66. No version bump or release is claimed.

Merge policy

Do not merge unless the live exact head remains current, every required check and security gate succeeds, all current findings are addressed, all threads are resolved, substantive exact-head review is complete, an eligible independent reviewer submits APPROVE, and enforceable branch protection is evidenced. Queued, pending, unexpectedly skipped, rate-limited, status-only, or intentionally RED signals are not success, and no protection may be bypassed or weakened.

Related: #9, #27, #29, #66

@coderabbitai

coderabbitai Bot commented Aug 5, 2026

Copy link
Copy Markdown

Warning

Review limit reached

@seonghobae, you've reached your PR review limit, so we couldn't start this review.

Next review available in: 9 minutes

Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available.
You're only billed for reviews past your plan's rate limits ($0.25/file).

How can I continue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews.

How do review limits work?

CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability.

For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window.

Please refer docs for additional details.

Review details
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 2ecfb769-6f01-4488-a721-ba74aa244bce

📥 Commits

Reviewing files that changed from the base of the PR and between 9adb784 and 5c2e676.

📒 Files selected for processing (27)
  • CHANGELOG.md
  • docs/doctoring/quarantined-patch-validation.md
  • docs/quarantined-patch-validation.md
  • reviewer/noema_reviewer/__init__.py
  • reviewer/noema_reviewer/patch_validation.py
  • reviewer/tests/test_patch_validation.py
  • reviewer/tests/test_patch_validation_archive_boundaries.py
  • reviewer/tests/test_patch_validation_blob_identity_edges.py
  • reviewer/tests/test_patch_validation_canonical_paths.py
  • reviewer/tests/test_patch_validation_coverage_edges.py
  • reviewer/tests/test_patch_validation_exact_tree_and_output.py
  • reviewer/tests/test_patch_validation_exact_tree_archive_binding.py
  • reviewer/tests/test_patch_validation_exact_tree_canonical_metadata.py
  • reviewer/tests/test_patch_validation_git_control_descriptor_edge.py
  • reviewer/tests/test_patch_validation_git_control_isolation.py
  • reviewer/tests/test_patch_validation_git_metadata_mask.py
  • reviewer/tests/test_patch_validation_hardening.py
  • reviewer/tests/test_patch_validation_mode_boundaries.py
  • reviewer/tests/test_patch_validation_object_alternates_boundary.py
  • reviewer/tests/test_patch_validation_path_consistency.py
  • reviewer/tests/test_patch_validation_prearchive_and_result_channel.py
  • reviewer/tests/test_patch_validation_provenance_and_hunk_edges.py
  • reviewer/tests/test_patch_validation_security_boundaries.py
  • reviewer/tests/test_patch_validation_source_integrity.py
  • reviewer/tests/test_patch_validation_streaming_edges.py
  • reviewer/tests/test_patch_validation_streaming_final_edges.py
  • reviewer/tests/test_patch_validation_streaming_git_output.py

Comment @coderabbitai help to get the list of available commands.

Comment thread reviewer/noema_reviewer/patch_validation.py Fixed
@seonghobae
seonghobae marked this pull request as ready for review August 5, 2026 07:16

Copy link
Copy Markdown
Contributor Author

@coderabbitai review

Please review exact current head c83fb483ede9c6378b7e89c3b92a49d767140119. Treat prior draft-skip status and findings anchored to older heads as stale. Focus on the credential boundary, raw diff-path parsing, descriptor-safe reads, Docker isolation, exact request/result binding, bounded evidence, tests, public documentation, and standards claims.

@coderabbitai

coderabbitai Bot commented Aug 5, 2026

Copy link
Copy Markdown

@seonghobae I will review pull request #65 at exact head c83fb483ede9c6378b7e89c3b92a49d767140119.

I will treat findings on earlier heads as stale. I will focus on the specified security boundaries, validation logic, evidence limits, tests, documentation, and standards claims.

⚠️ Action not completed

Review rate limited.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

Copy link
Copy Markdown
Contributor Author

@opencode-agent @cwl-noema-review

Independent exact-head review requested for c83fb483ede9c6378b7e89c3b92a49d767140119. Please submit a GitHub APPROVE only if this exact head satisfies repository policy, security boundaries, tests, documentation, and required checks. GitHub's formal reviewer-request endpoint rejected these identities because one or both are not repository collaborators; this comment does not substitute for an eligible independent approval.

Comment thread .github/workflows/repair-pr65-reviewer-ci.yml Fixed

Copy link
Copy Markdown
Contributor Author

@opencode-agent

Implement the valid exact-head CI finding on current head b1b00fa2dc97335b5a7192e13f34fb46565bbd0a; refuse to write if the head moves.

reviewer-ci remains red because test_runner_rejects_non_exact_source_worktree_before_docker[tracked|untracked] proves that a Git checkout with tracked or untracked drift still reaches Docker. Add a fail-closed, non-shell, bounded git status --porcelain=v1 --untracked-files=all preflight using TRUSTED_GIT_EXECUTABLE and the existing scrubbed Git environment before sandbox launch. A dirty or unverifiable Git worktree must raise before Docker. Preserve the separately documented behavior for authenticated non-Git source snapshots. Keep the tests test-first, maintain 100% production statement/branch and public-docstring coverage, update authoritative docs/CHANGELOG only where the contract changes, then verify all checks against the new exact head. Do not alter the existing review-agent key contract; use the development agent's NVIDIA NIM credential path only.

@coderabbitai

coderabbitai Bot commented Aug 6, 2026

Copy link
Copy Markdown

Tip

For best results, initiate chat on the files or code changes.

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
set -euo pipefail

repo="ContextualWisdomLab/noema"
pr="65"
base="9adb784902cae19a150146a8fadd6a0491f67814"
head="5d6360556e7b43e33ece67efd5e41db4ec740615"

before=$(gh pr view "$pr" --repo "$repo" --json baseRefOid,headRefOid --jq '.baseRefOid + " " + .headRefOid')
checked_out=$(git rev-parse HEAD)
resolved_base=$(git rev-parse "${base}^{commit}")
resolved_head=$(git rev-parse "${head}^{commit}")
printf 'REVISION_BEFORE checked_out=%s resolved_base=%s resolved_head=%s live=%s\n' \
  "$checked_out" "$resolved_base" "$resolved_head" "$before"

printf '%s\n' '== Changed files =='
git diff --name-status "$resolved_base" "$resolved_head"

printf '%s\n' '== Implementation outline =='
ast-grep outline reviewer/noema_reviewer/patch_validation.py --items all --view signatures

printf '%s\n' '== Security-relevant implementation locations =='
rg -n -C 4 \
  '^(def (_validated_exact_tree_record|_stream|_preflight|_materialize|_verify|_read|_validated_repository_path|inspect_patch_bytes|validate)|class )|MODE_METADATA_PATTERN|git (status|ls-tree|archive)|Popen|O_NOFOLLOW|fstat|lstat|MAX_|sha(1|256)|object_id|--network|--read-only|--user=|cap-drop|no-new-privileges|--pull=never|result\.json|GIT_NO_' \
  reviewer/noema_reviewer/patch_validation.py

printf '%s\n' '== Focused implementation sections =='
sed -n '1,260p' reviewer/noema_reviewer/patch_validation.py
sed -n '260,760p' reviewer/noema_reviewer/patch_validation.py
sed -n '760,1260p' reviewer/noema_reviewer/patch_validation.py
sed -n '1260,1600p' reviewer/noema_reviewer/patch_validation.py

printf '%s\n' '== Focused patch-validation tests =='
fd -t f -a . reviewer/tests | rg 'patch_validation' | sort
rg -n -C 3 \
  'def test_.*(tree|canonical|padding|archive|extract|status|worktree|result|descriptor|hunk|mode|path|docker|timeout|bound|identity|blob)' \
  reviewer/tests

printf '%s\n' '== Documentation, changelog, and workflow changes =='
rg -n -C 3 \
  '(patch validation|exact tree|ls-tree|padding|archive|extract|credential|Docker|result\.json|mode metadata|APA|NIST|SLSA)' \
  README.md CHANGELOG.md docs 2>/dev/null || true
git diff -- "$resolved_base" "$resolved_head" -- .github/workflows
rg -n -i -C 2 \
  '(contents:\s*write|permissions:.*write|repair[-_ ]?pr|self[-_ ]?modif|git push|gh pr|COPILOT_GITHUB_TOKEN)' \
  .github 2>/dev/null || true

printf '%s\n' '== Review state and non-success checks =='
gh pr view "$pr" --repo "$repo" --json reviewDecision,statusCheckRollup \
  --jq '{reviewDecision, checks:[.statusCheckRollup[] | select(.conclusion != "SUCCESS") | {name,status,conclusion}]}'

after=$(gh pr view "$pr" --repo "$repo" --json baseRefOid,headRefOid --jq '.baseRefOid + " " + .headRefOid')
printf 'REVISION_AFTER live=%s\n' "$after"

if [ "$checked_out" != "$resolved_head" ] ||
   [ "$before" != "$resolved_base $resolved_head" ] ||
   [ "$after" != "$resolved_base $resolved_head" ]; then
  echo 'EXACT_REVISION_MISMATCH_OR_CHANGED' >&2
  exit 2
fi

Length of output: 196101


🏁 Script executed:

#!/bin/bash
set -euo pipefail

repo="ContextualWisdomLab/noema"
pr="65"
base="9adb784902cae19a150146a8fadd6a0491f67814"
head="5d6360556e7b43e33ece67efd5e41db4ec740615"

printf '== Exact revision before targeted read ==\n'
git rev-parse HEAD
gh pr view "$pr" --repo "$repo" --json baseRefOid,headRefOid --jq '{baseRefOid,headRefOid}'

printf '== Definitions and call paths ==\n'
rg -n \
  '^(def (_validated_exact_tree_record|_stream_exact_tree|_preflight|_materialize|_extract|_verify|_read|_run|inspect_patch_bytes|validate)|class )' \
  reviewer/noema_reviewer/patch_validation.py

printf '== Exact-tree parser and preflight ==\n'
line=$(rg -n 'def _validated_exact_tree_record' reviewer/noema_reviewer/patch_validation.py | cut -d: -f1 | head -1)
sed -n "$((line-25)),$((line+250))p" reviewer/noema_reviewer/patch_validation.py

printf '== Archive, extraction, and source-digest verification ==\n'
rg -n -C 8 \
  '(TarFile|tarfile|extract|archive|expected_entries|inventory|blob|object_id|hashlib|sha1|sha256|git hash-object|cat-file|lstat)' \
  reviewer/noema_reviewer/patch_validation.py

printf '== Patch grammar and mode parser ==\n'
line=$(rg -n 'def inspect_patch_bytes' reviewer/noema_reviewer/patch_validation.py | cut -d: -f1 | head -1)
sed -n "$((line-40)),$((line+360))p" reviewer/noema_reviewer/patch_validation.py

printf '== Result channel and Docker command ==\n'
rg -n -C 8 \
  '(result\.json|subprocess\.run|Popen|docker|--network|--read-only|--user=|cap-drop|no-new-privileges|DEVNULL|timeout)' \
  reviewer/noema_reviewer/patch_validation.py

printf '== Archive and exact-tree regression tests ==\n'
fd -t f -a . reviewer/tests | rg 'patch_validation.*(archive|tree|output|prearchive|canonical)' | sort | \
  while IFS= read -r file; do
    printf '\n== %s ==\n' "$file"
    cat -n "$file"
  done

printf '== Workflow additions in this PR only ==\n'
git diff --name-status "$base" "$head" -- .github/workflows
git diff -- "$base" "$head" -- .github/workflows | rg -n -i -C 3 \
  '(repair|self[-_ ]?modif|contents:\s*write|git push|gh pr)' || true

printf '== Exact revision after targeted read ==\n'
git_head=$(git rev-parse HEAD)
live=$(gh pr view "$pr" --repo "$repo" --json baseRefOid,headRefOid --jq '.baseRefOid + " " + .headRefOid')
printf 'checked_out=%s live=%s\n' "$git_head" "$live"
if [ "$git_head" != "$head" ] || [ "$live" != "$base $head" ]; then
  echo 'EXACT_REVISION_MISMATCH_OR_CHANGED' >&2
  exit 2
fi

Length of output: 103836


@seonghobae I completed a substantive review of base 9adb784902cae19a150146a8fadd6a0491f67814 and head 5d6360556e7b43e33ece67efd5e41db4ec740615.

I found one blocking issue. I do not approve this head.

Blocking: the authenticated exact-tree preflight is not bound to the archive or extracted file bytes.

  • reviewer/noema_reviewer/patch_validation.py, Line 947, validates each git ls-tree record. It retains only a path set and aggregate byte counts.
  • reviewer/noema_reviewer/patch_validation.py, Line 1062, performs that validation before git archive. This correctly enforces prearchive limits.
  • reviewer/noema_reviewer/patch_validation.py, Line 1096, creates expected_entries from the archive. Each entry contains only path, type, and size.
  • reviewer/noema_reviewer/patch_validation.py, Line 1156, compares the extracted snapshot only with this archive-derived manifest.

The code does not retain the authenticated tree’s path, mode, blob object ID, and size. It does not compare archive entries with that inventory. It does not recompute Git blob identities from extracted regular-file bytes.

Therefore, a structurally valid archive can omit a committed file, add a file, rename a file, change a mode, or replace a blob with different content of the same size. The current archive and extraction checks can accept these cases because both use the archive as their source of truth.

Retain a bounded immutable exact-tree inventory during the streamed preflight. Bind every archive regular file to the inventory’s canonical path, mode, size, and object ID. Before Docker starts, recompute each extracted file’s Git-format blob object ID and require an exact match.

Add regressions for:

  1. Omitted, added, and renamed archive paths.
  2. Mode drift.
  3. Same-size and different-size blob substitution.
  4. Archive object-ID mismatch.
  5. Post-extraction byte substitution.
  6. Malformed or duplicate exact-tree inventory entries.

The requested base and head remained unchanged before and after inspection. I found no new repair workflow in the PR workflow diff.

You are interacting with an AI system.

Copy link
Copy Markdown
Contributor Author

@opencode-agent

Continue only from exact current head dd5813a7c761a44b479bcac70c2e5fcec8dacf85; abort without writing if the live PR head differs before commit.

The RED exact-head reviewer run is 31068508274 / job 92511352276: the four new tests in reviewer/tests/test_patch_validation_object_alternates_boundary.py fail exactly as intended while the prior 342 tests still pass and pre-existing production coverage remains 100%. Current code follows source-local .git/objects/info/alternates transitively, so a clean repository can borrow an exact head and private blobs from another host object store and mount those bytes into the untrusted validator container. Git's current primary documentation explicitly states that objects/info/alternates and GIT_ALTERNATE_OBJECT_DIRECTORIES let an incomplete repository borrow objects from other stores, and objects/info/http-alternates records alternate URLs.

Implement the smallest fail-closed production boundary in reviewer/noema_reviewer/patch_validation.py:

  • after resolving the source object directory and before writing it into the private control's alternates record, check objects/info/alternates and objects/info/http-alternates with os.lstat;
  • if either entry exists in any filesystem shape, reject with a stable message containing alternate object database;
  • treat non-FileNotFoundError inspection failures as source Git alternate object metadata is unavailable;
  • do not parse, traverse, permit, copy, or recursively trust borrowed stores;
  • preserve ordinary self-contained repositories and linked-worktree/common-directory handling;
  • add the Git repository-layout source to docs/doctoring/quarantined-patch-validation.md in APA 7 style, update public docs and CHANGELOG.md to state that source-local filesystem and HTTP alternates are refused;
  • preserve all patch grammar, streamed bounds, archive equality, descriptor-safe result channel, Docker isolation, and existing diagnostics unrelated to this boundary.

No workflows, repair scripts, skips, ignores, test-name branches, global/autouse monkeypatches, credential changes, or unrelated edits. Run the focused file first, then the complete reviewer suite. Commit only with all tests passing, 100% production statement/branch coverage, and 100% public docstrings. Do not merge.

Comment thread reviewer/tests/test_patch_validation_exact_tree_archive_binding.py Fixed

seonghobae commented Aug 6, 2026

Copy link
Copy Markdown
Contributor Author

@opencode-agent

Continue only from exact current head 5da28dffd68a04375382f2383899653af8d5ec80; abort without writing if the live head differs before every commit.

Exact-head RED evidence is reviewer run 31069459256, job 92514141112: 11 expected failures, 343 passes, while ci and Security Scan both succeed and the pre-existing 1,424 statements / 458 branches remain at 100%. Seven failures prove that the authenticated streamed ls-tree result is discarded and the archive is incorrectly used as its own source of truth; four failures prove that source-local filesystem/HTTP alternates can import another repository's private object graph into the sandbox.

Implement both trust-boundary fixes without weakening any existing control.

A. Refuse borrowed Git object databases

  • After resolving the source/common object directory and before writing it into the private control, inspect objects/info/alternates and objects/info/http-alternates with os.lstat.
  • If either path exists in any filesystem shape, reject with a stable message containing alternate object database.
  • Treat non-FileNotFoundError inspection failures as source Git alternate object metadata is unavailable.
  • Do not parse, traverse, copy, recursively trust, or permit borrowed object stores or URLs.
  • Preserve self-contained repositories and linked-worktree/common-directory handling.

B. Bind authenticated exact tree → archive → extracted bytes

  • Retain a bounded immutable inventory from the streamed git ls-tree -r -l -z --full-tree preflight. Every canonical file entry must include Git mode (100644/100755), object ID (SHA-1 or SHA-256), and byte size.
  • Keep the existing 20,000-record, per-record/path, 16 MiB metadata, 64 MiB per-blob, and 512 MiB aggregate limits; do not reintroduce unbounded collection. A bounded mapping or immutable tuple of at most 20,000 entries is acceptable.
  • Require the archive's regular-file set to equal the inventory exactly: no omission, addition, or rename. Require each archive file's size and executable-bit-derived Git mode to match the inventory. Directory records remain auxiliary but must retain all existing path/collision/population checks.
  • After extraction and immediately before Docker receives the snapshot, descriptor-safely reopen every regular file without following symlinks, recheck type/inode/size, derive the Git-format blob object ID by hashing b"blob " + ascii(size) + b"\0" + file_bytes, select SHA-1 for 40-hex IDs and SHA-256 for 64-hex IDs, and require exact object-ID equality. Stream the bytes; do not load a 64 MiB blob into one new buffer.
  • Require the extracted file set, sizes, executable modes, and object IDs to equal the authenticated inventory. Reject same-size and different-size substitutions, mode drift, post-extraction replacement, and archive/object-ID mismatch with the existing materialized safely outer boundary.
  • Preserve direct regressions for malformed and duplicate exact-tree records and update existing private helper tests only where the returned inventory changes their contract.

Documentation and quality

  • Update docs/quarantined-patch-validation.md, docs/doctoring/quarantined-patch-validation.md, and CHANGELOG.md to state the implemented contract: source-local alternates/http-alternates are refused; the immutable exact-tree path/mode/size/OID inventory is matched to archive members; extracted bytes are Git-blob rehashed before Docker.
  • Add current primary Git documentation in APA 7 style for repository layout/alternates, git ls-tree, and Git object hashing where needed. Do not claim image publication or runtime activation.
  • Run the two focused files first, then the complete reviewer suite. Finish only with all tests passing, production statement and branch coverage 100%, public docstrings 100%, and no regressions in the real no-network sandbox lane.

No workflows, repair scripts, self-modifying Actions, contents: write branch patchers, skips, ignores, test-name branches, global/autouse monkeypatches, credential changes, or unrelated edits. Do not merge.

seonghobae commented Aug 6, 2026

Copy link
Copy Markdown
Contributor Author

@cwl-noema-review

Review exact RED head 5da28dffd68a04375382f2383899653af8d5ec80 against base 9adb784902cae19a150146a8fadd6a0491f67814. The only change from the previously named head is removal of an unused test import; production behavior and the 11-failure test-first contract are unchanged. Do not approve and do not restate the known failures. Inspect the proposed repair contract for additional actionable gaps only: source-local filesystem/HTTP alternate object stores, bounded immutable exact-tree inventory, exact archive file-set/mode/size binding, SHA-1/SHA-256 Git blob rehash after extraction, descriptor and race boundaries, memory ceilings, and documentation accuracy. Report any additional fail-open case not already covered by test_patch_validation_object_alternates_boundary.py or test_patch_validation_exact_tree_archive_binding.py.

@seonghobae
seonghobae marked this pull request as draft August 6, 2026 04:00

Copy link
Copy Markdown
Contributor Author

@opencode-agent address

Repair exact current head 5da28dffd68a04375382f2383899653af8d5ec80 test-first without weakening the 11 intentionally RED security contracts. Refuse regular-file .git/objects/info/alternates and http-alternates before any Git object read, rejecting nonempty source-local filesystem or HTTP alternate configuration with stable redacted diagnostics. Retain the authenticated streamed git ls-tree -r -l -z --full-tree inventory as immutable bounded records of canonical path, mode, object ID, and size; require the archive and extracted tree to match its complete regular-file set, modes, and sizes; then descriptor-safely rehash every extracted regular file with the repository object format using blob <size>\0<bytes> and require the computed SHA-1 or SHA-256 object ID to equal the inventory before Docker starts. Add adversarial tests for both alternate files, missing/extra/renamed/type/mode/size/content archive drift, SHA-1 and SHA-256 repositories, bounded streaming, symlink races, oversized files, and cleanup. Preserve no-network/read-only/non-root Docker isolation, exact-head binding, 100% statement/branch coverage, complete public docstrings, CHANGELOG, and APA 7 doctoring. Keep Draft until all 354+ tests and every exact-head security/review gate are green.

@seonghobae
seonghobae marked this pull request as ready for review August 6, 2026 05:03

Copy link
Copy Markdown
Contributor Author

@coderabbitai review

Please perform a substantive review of exact current head d29abd455759c1b8f3c4a5b04316395b4daff03f. Treat all draft-skip output and findings anchored to earlier heads as stale. Focus on exact-tree inventory retention, archive path/mode/size equality, descriptor-safe SHA-1/SHA-256 Git blob identity verification, alternate-object-database rejection, bounded streaming and early termination, patch grammar, the result channel, Docker isolation, authoritative documentation and doctoring, and the exact-head 100% production coverage and public-docstring evidence. Do not treat a commit status as approval.

@opencode-agent @cwl-noema-review

Independent exact-head review is requested for d29abd455759c1b8f3c4a5b04316395b4daff03f. Submit GitHub APPROVE only if this exact head satisfies repository policy, enforceable branch protection, security boundaries, tests, documentation, evidence separation, and every required check. A comment, model judgement, or commit status is not approval.

@coderabbitai

coderabbitai Bot commented Aug 6, 2026

Copy link
Copy Markdown

Tip

For best results, initiate chat on the files or code changes.

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
set -euo pipefail

repo="ContextualWisdomLab/noema"
pr="65"
base="9adb784902cae19a150146a8fadd6a0491f67814"
head="d29abd455759c1b8f3c4a5b04316395b4daff03f"

live_before="$(gh pr view "$pr" --repo "$repo" --json baseRefOid,headRefOid --jq '.baseRefOid + " " + .headRefOid')"
checked_out="$(git rev-parse HEAD)"
resolved_base="$(git rev-parse "${base}^{commit}")"
resolved_head="$(git rev-parse "${head}^{commit}")"
printf 'REVISION_BEFORE checked_out=%s resolved_base=%s resolved_head=%s live=%s\n' \
  "$checked_out" "$resolved_base" "$resolved_head" "$live_before"

printf '\n== Changed files ==\n'
git diff --name-status "$resolved_base" "$resolved_head"
git diff --stat "$resolved_base" "$resolved_head"

printf '\n== Production structure ==\n'
ast-grep outline reviewer/noema_reviewer/patch_validation.py --items all --view signatures

printf '\n== Security-relevant symbols and call paths ==\n'
rg -n -C 5 \
  '^(def (_validated_exact_tree_record|_stream_exact_tree|_verify|_materialize|_extract|_read|_run|_preflight|inspect_patch_bytes|validate)|class )|alternates|http-alternates|ls-tree|git archive|git status|O_NOFOLLOW|fstat|lstat|openat|Popen|PIPE|MAX_|MODE_METADATA_PATTERN|fullmatch|sha1|sha256|blob |--network|--read-only|--user=|cap-drop|no-new-privileges|--pull=never|result\.json|DEVNULL|GIT_NO_' \
  reviewer/noema_reviewer/patch_validation.py

printf '\n== Exact-tree, archive, extraction, and object identity code ==\n'
rg -n -C 12 \
  '(_validated_exact_tree_record|inventory|archive|extract|object_id|blob |hashlib|sha1|sha256|TarFile|tarfile|O_NOFOLLOW|fstat|lstat)' \
  reviewer/noema_reviewer/patch_validation.py

printf '\n== Patch grammar and mode metadata code ==\n'
rg -n -C 10 \
  '(inspect_patch_bytes|MODE_METADATA_PATTERN|diff --git|old mode|new mode|new file mode|deleted file mode|fullmatch|hunk|@@ |rename from|rename to|copy from|copy to)' \
  reviewer/noema_reviewer/patch_validation.py

printf '\n== Docker and result-channel code ==\n'
rg -n -C 10 \
  '(result\.json|docker|--network|--read-only|--user=|cap-drop|no-new-privileges|--pull=never|DEVNULL|timeout|Popen)' \
  reviewer/noema_reviewer/patch_validation.py

printf '\n== Relevant test files ==\n'
fd -t f -a . reviewer/tests | rg 'patch_validation' | sort
rg -n -C 3 \
  'def test_.*(alternate|tree|archive|extract|blob|sha|descriptor|result|docker|mode|path|hunk|bound|timeout|worktree)' \
  reviewer/tests

printf '\n== Documentation and changelog claims ==\n'
rg -n -C 4 \
  '(patch validation|exact tree|alternates|http-alternates|ls-tree|archive|Git blob|SHA-1|SHA-256|Docker|result\.json|APA|100%)' \
  CHANGELOG.md docs README.md 2>/dev/null || true

printf '\n== Workflow privilege scan ==\n'
git diff --name-status "$resolved_base" "$resolved_head" -- .github/workflows
rg -n -i -C 3 \
  '(contents:\s*write|permissions:.*write|repair[-_ ]?pr|self[-_ ]?modif|git push|gh pr|COPILOT_GITHUB_TOKEN)' \
  .github 2>/dev/null || true

printf '\n== Check and review state ==\n'
gh pr view "$pr" --repo "$repo" --json reviewDecision,statusCheckRollup \
  --jq '{reviewDecision, checks:[.statusCheckRollup[] | {name,status,conclusion,detailsUrl}]}'

printf '\n== Unresolved review threads ==\n'
gh api graphql -F owner='ContextualWisdomLab' -F name='noema' -F number="$pr" -f query='
query($owner: String!, $name: String!, $number: Int!) {
  repository(owner: $owner, name: $name) {
    pullRequest(number: $number) {
      reviewThreads(first: 100) {
        nodes {
          isResolved
          path
          line
          comments(first: 1) { nodes { author { login } body } }
        }
      }
    }
  }
}' --jq '.data.repository.pullRequest.reviewThreads.nodes[] | select(.isResolved == false)' || true

live_after="$(gh pr view "$pr" --repo "$repo" --json baseRefOid,headRefOid --jq '.baseRefOid + " " + .headRefOid')"
printf '\nREVISION_AFTER live=%s checked_out=%s\n' "$live_after" "$(git rev-parse HEAD)"

if [ "$checked_out" != "$resolved_head" ] ||
   [ "$live_before" != "$resolved_base $resolved_head" ] ||
   [ "$live_after" != "$resolved_base $resolved_head" ]; then
  echo 'EXACT_REVISION_MISMATCH_OR_CHANGED' >&2
  exit 2
fi

Length of output: 196223


🏁 Script executed:

#!/bin/bash
set -euo pipefail

repo="ContextualWisdomLab/noema"
pr="65"
base="9adb784902cae19a150146a8fadd6a0491f67814"
head="d29abd455759c1b8f3c4a5b04316395b4daff03f"

before="$(gh pr view "$pr" --repo "$repo" --json baseRefOid,headRefOid --jq '.baseRefOid + " " + .headRefOid')"
test "$(git rev-parse HEAD)" = "$head"
test "$before" = "$base $head"

printf '%s\n' '== Production symbols =='
rg -n \
  '^(def (_source_object_directory|_validated_exact_tree_record|_stream_exact_tree|_materialize|_verify_git_blob_identity|_read_regular|_run_git|inspect_patch_bytes|validate)|class (ExactTree|DockerPatch|PatchValidation))' \
  reviewer/noema_reviewer/patch_validation.py

show_function() {
  local symbol="$1"
  local start
  start="$(rg -n "^def ${symbol}\b" reviewer/noema_reviewer/patch_validation.py | head -1 | cut -d: -f1)"
  if [ -n "$start" ]; then
    sed -n "$((start-12)),$((start+240))p" reviewer/noema_reviewer/patch_validation.py
  fi
}

printf '%s\n' '== Source object directory and alternates boundary =='
show_function "_source_object_directory"

printf '%s\n' '== Exact-tree record parser and streaming inventory =='
show_function "_validated_exact_tree_record"
show_function "_stream_exact_tree"

printf '%s\n' '== Archive materialization and extracted snapshot verification =='
show_function "_materialize"
show_function "_verify_git_blob_identity"

printf '%s\n' '== Patch parser =='
show_function "inspect_patch_bytes"

printf '%s\n' '== Validation orchestrator and Docker launch =='
show_function "validate"

printf '%s\n' '== Exact-tree/archive binding regressions =='
cat -n reviewer/tests/test_patch_validation_exact_tree_archive_binding.py
printf '%s\n' '== Alternate-object-database regressions =='
cat -n reviewer/tests/test_patch_validation_object_alternates_boundary.py
printf '%s\n' '== Blob identity edge regressions =='
cat -n reviewer/tests/test_patch_validation_blob_identity_edges.py
printf '%s\n' '== Mode metadata regressions =='
cat -n reviewer/tests/test_patch_validation_mode_boundaries.py
printf '%s\n' '== Result and Docker regressions =='
cat -n reviewer/tests/test_patch_validation_exact_tree_and_output.py

printf '%s\n' '== Public documentation: materialization and result sections =='
sed -n '24,130p' docs/quarantined-patch-validation.md
printf '%s\n' '== Doctoring: materialization and metadata sections =='
sed -n '41,160p' docs/doctoring/quarantined-patch-validation.md

after="$(gh pr view "$pr" --repo "$repo" --json baseRefOid,headRefOid --jq '.baseRefOid + " " + .headRefOid')"
printf 'REVISION_AFTER live=%s checked_out=%s\n' "$after" "$(git rev-parse HEAD)"
test "$after" = "$base $head"

Length of output: 22995


🏁 Script executed:

#!/bin/bash
set -euo pipefail

repo="ContextualWisdomLab/noema"
pr="65"
base="9adb784902cae19a150146a8fadd6a0491f67814"
head="d29abd455759c1b8f3c4a5b04316395b4daff03f"

before="$(gh pr view "$pr" --repo "$repo" --json baseRefOid,headRefOid --jq '.baseRefOid + " " + .headRefOid')"
test "$(git rev-parse HEAD)" = "$head"
test "$before" = "$base $head"

printf '%s\n' '== Archive, extraction, and blob verification implementation =='
sed -n '1060,1417p' reviewer/noema_reviewer/patch_validation.py

printf '%s\n' '== Runner orchestration and Docker isolation implementation =='
sed -n '1418,1740p' reviewer/noema_reviewer/patch_validation.py

printf '%s\n' '== Exact-tree/archive binding regression assertions =='
sed -n '1,320p' reviewer/tests/test_patch_validation_exact_tree_archive_binding.py

printf '%s\n' '== Alternate-object-database regression assertions =='
sed -n '1,160p' reviewer/tests/test_patch_validation_object_alternates_boundary.py

printf '%s\n' '== Blob identity regression assertions =='
sed -n '1,380p' reviewer/tests/test_patch_validation_blob_identity_edges.py

printf '%s\n' '== Mode metadata regression assertions =='
sed -n '1,180p' reviewer/tests/test_patch_validation_mode_boundaries.py

printf '%s\n' '== Changed patch-validation files in the exact PR diff =='
git diff --unified=35 "$base" "$head" -- \
  reviewer/noema_reviewer/patch_validation.py \
  reviewer/tests/test_patch_validation_exact_tree_archive_binding.py \
  reviewer/tests/test_patch_validation_object_alternates_boundary.py \
  reviewer/tests/test_patch_validation_blob_identity_edges.py \
  docs/quarantined-patch-validation.md \
  docs/doctoring/quarantined-patch-validation.md \
  CHANGELOG.md

printf '%s\n' '== Public documentation statements for inventory and blob identity =='
rg -n -C 3 \
  '(inventory|exact Git tree|exact-tree|object ID|object identity|blob rehash|rehash|SHA-1|SHA-256|archive|extraction)' \
  docs/quarantined-patch-validation.md docs/doctoring/quarantined-patch-validation.md CHANGELOG.md

after="$(gh pr view "$pr" --repo "$repo" --json baseRefOid,headRefOid --jq '.baseRefOid + " " + .headRefOid')"
printf 'REVISION_AFTER live=%s checked_out=%s\n' "$after" "$(git rev-parse HEAD)"
test "$after" = "$base $head"

Length of output: 224205


@seonghobae I completed a substantive review of base 9adb784902cae19a150146a8fadd6a0491f67814 and head d29abd455759c1b8f3c4a5b04316395b4daff03f.

I found one actionable documentation issue. I do not approve this PR.

P2 — Document the exact-tree identity and alternate-object boundaries

reviewer/noema_reviewer/patch_validation.py implements stronger controls than the authoritative documentation describes:

  • _source_object_directory rejects any source-local objects/info/alternates or objects/info/http-alternates.
  • _consume_exact_tree_stream retains a bounded canonical path, mode, object-ID, and size inventory.
  • _validated_source_archive_members requires archive file-set, mode, and size equality with that inventory.
  • _verify_git_blob_identity descriptor-safely rehashes extracted bytes as Git SHA-1 or SHA-256 blobs before Docker starts.

However, docs/quarantined-patch-validation.md Lines 64-70 and docs/doctoring/quarantined-patch-validation.md Lines 76-90 describe only archive validation and archive-manifest-to-extraction equality. They do not state:

  1. Source-local filesystem and HTTP alternate object databases are refused.
  2. The archive regular-file set, mode, and size must equal the authenticated exact-tree inventory.
  3. Extracted regular-file bytes are rehashed with Git blob <size>\0<bytes> identity and matched to the inventory object ID.

This omission is material because these controls close the source-substitution cases that the PR adds. Update both documents and the CHANGELOG.md Unreleased entry to describe this contract and its SHA-1/SHA-256 verification.

The requested base and head remained unchanged during inspection. The check rollup is successful for the primary CI, reviewer, and security jobs. That evidence does not replace an eligible independent approval or enforceable branch-protection evidence.

You are interacting with an AI system.

Copy link
Copy Markdown
Contributor Author

@coderabbitai review
@cwl-noema-review
@opencode-agent

Please review exact current head d29abd455759c1b8f3c4a5b04316395b4daff03f. Exact-head CI, Security Scan, reviewer CI, 370 tests, 1,497 production statements and 492 branches at 100%, 100% public docstrings, signed distroless sandbox verification, zero configured-severity vulnerabilities, and all visible review-thread resolutions are current. Review only; do not update the branch, enable auto-merge, merge, publish the validator image, release, deploy, or alter branch protection.

@coderabbitai

coderabbitai Bot commented Aug 6, 2026

Copy link
Copy Markdown

Tip

For best results, initiate chat on the files or code changes.

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
set -euo pipefail

repo="ContextualWisdomLab/noema"
pr="65"
base="9adb784902cae19a150146a8fadd6a0491f67814"
head="d29abd455759c1b8f3c4a5b04316395b4daff03f"

live_before="$(gh pr view "$pr" --repo "$repo" --json baseRefOid,headRefOid --jq '.baseRefOid + " " + .headRefOid')"
checked_out="$(git rev-parse HEAD)"
resolved_base="$(git rev-parse "${base}^{commit}")"
resolved_head="$(git rev-parse "${head}^{commit}")"
printf 'REVISION_BEFORE checked_out=%s requested_base=%s requested_head=%s live=%s\n' \
  "$checked_out" "$resolved_base" "$resolved_head" "$live_before"

printf '\n== Changed files ==\n'
git diff --name-status "$resolved_base" "$resolved_head"

printf '\n== Implementation outline ==\n'
ast-grep outline reviewer/noema_reviewer/patch_validation.py --items all --view signatures

printf '\n== Security-relevant implementation ==\n'
rg -n -C 5 \
  '^(def (_source_object_directory|_validated_exact_tree_record|_consume_exact_tree_stream|_validated_source_archive_members|_verify_git_blob_identity|_materialize|_read|_run|inspect_patch_bytes|validate)|class )|alternates|http-alternates|ls-tree|git archive|git status|O_NOFOLLOW|fstat|lstat|MAX_|MODE_METADATA_PATTERN|fullmatch|sha1|sha256|blob |--network|--read-only|--user=|cap-drop|no-new-privileges|--pull=never|result\.json|DEVNULL|GIT_NO_' \
  reviewer/noema_reviewer/patch_validation.py

printf '\n== Targeted implementation sections ==\n'
for symbol in _source_object_directory _validated_exact_tree_record _consume_exact_tree_stream _validated_source_archive_members _verify_git_blob_identity inspect_patch_bytes validate; do
  line="$(rg -n "^def ${symbol}\b" reviewer/noema_reviewer/patch_validation.py | head -1 | cut -d: -f1 || true)"
  if [ -n "$line" ]; then
    start=$((line > 15 ? line - 15 : 1))
    end=$((line + 210))
    printf '\n== %s, Lines %s-%s ==\n' "$symbol" "$start" "$end"
    sed -n "${start},${end}p" reviewer/noema_reviewer/patch_validation.py
  fi
done

printf '\n== Boundary regression tests ==\n'
for file in \
  reviewer/tests/test_patch_validation_exact_tree_archive_binding.py \
  reviewer/tests/test_patch_validation_object_alternates_boundary.py \
  reviewer/tests/test_patch_validation_blob_identity_edges.py \
  reviewer/tests/test_patch_validation_mode_boundaries.py \
  reviewer/tests/test_patch_validation_exact_tree_and_output.py; do
  if [ -f "$file" ]; then
    printf '\n== %s ==\n' "$file"
    cat -n "$file"
  fi
done

printf '\n== Documentation and CHANGELOG contract ==\n'
rg -n -C 5 \
  '(alternate object|alternates|http-alternates|exact-tree|exact tree|inventory|archive|Git blob|blob identity|SHA-1|SHA-256|rehash|object ID|object-id)' \
  docs/quarantined-patch-validation.md \
  docs/doctoring/quarantined-patch-validation.md \
  CHANGELOG.md

printf '\n== Workflow diff and privilege scan ==\n'
git diff --name-status "$resolved_base" "$resolved_head" -- .github/workflows
git diff -- "$resolved_base" "$resolved_head" -- .github/workflows
rg -n -i -C 2 \
  '(contents:\s*write|permissions:.*write|repair[-_ ]?pr|self[-_ ]?modif|git push|gh pr|COPILOT_GITHUB_TOKEN)' \
  .github 2>/dev/null || true

printf '\n== Check and thread state ==\n'
gh pr view "$pr" --repo "$repo" --json reviewDecision,statusCheckRollup \
  --jq '{reviewDecision, checks:[.statusCheckRollup[] | {name,status,conclusion,detailsUrl}]}'
gh api graphql -F owner='ContextualWisdomLab' -F name='noema' -F number="$pr" -f query='
query($owner: String!, $name: String!, $number: Int!) {
  repository(owner: $owner, name: $name) {
    pullRequest(number: $number) {
      reviewThreads(first: 100) {
        nodes {
          isResolved
          path
          line
          comments(first: 1) { nodes { author { login } body } }
        }
      }
    }
  }
}' --jq '.data.repository.pullRequest.reviewThreads.nodes[] | select(.isResolved == false)' || true

live_after="$(gh pr view "$pr" --repo "$repo" --json baseRefOid,headRefOid --jq '.baseRefOid + " " + .headRefOid')"
printf '\nREVISION_AFTER checked_out=%s live=%s\n' "$(git rev-parse HEAD)" "$live_after"

if [ "$checked_out" != "$resolved_head" ] ||
   [ "$live_before" != "$resolved_base $resolved_head" ] ||
   [ "$live_after" != "$resolved_base $resolved_head" ]; then
  echo 'EXACT_REVISION_MISMATCH_OR_CHANGED' >&2
  exit 2
fi

Length of output: 194965


@seonghobae I completed a read-only review of base 9adb784902cae19a150146a8fadd6a0491f67814 and head d29abd455759c1b8f3c4a5b04316395b4daff03f.

I found one current actionable issue. I do not approve this PR.

P2 — Document the exact-tree authentication controls

reviewer/noema_reviewer/patch_validation.py implements controls that the authoritative documentation does not fully state:

  • _source_object_directory rejects source-local objects/info/alternates and objects/info/http-alternates.
  • _consume_exact_tree_stream retains the bounded exact-tree inventory of canonical path, Git mode, object ID, and size.
  • _validated_source_archive_members requires archive regular-file path, executable-derived mode, size, and full file set to match that inventory.
  • _verify_git_blob_identity uses descriptor-safe streaming to verify extracted bytes as blob <size>\0<bytes> with SHA-1 or SHA-256 before Docker starts.

However, docs/quarantined-patch-validation.md Lines 64-72 describes archive-manifest validation and extraction equality only. docs/doctoring/quarantined-patch-validation.md Lines 76-96 has the same omission. Neither document states the source-local alternate-object rejection, the authenticated exact-tree-to-archive binding, or the extracted Git blob identity verification.

Update both documents and the CHANGELOG.md Unreleased entry. State the complete contract and the SHA-1/SHA-256 verification. This information is necessary to describe the implemented source-substitution boundary accurately.

The requested base and head remained unchanged during inspection. The relevant CI, reviewer, and security checks completed successfully. The skipped cancel-closed-pr-runs job is not review evidence.

You are interacting with an AI system.

Copy link
Copy Markdown
Contributor Author

@coderabbitai review

@opencode-agent @cwl-noema-review Independently review exact current head d29abd455759c1b8f3c4a5b04316395b4daff03f against protected main at 9adb784902cae19a150146a8fadd6a0491f67814. Exact-head ci 31071252542, Security Scan 31071252592, and reviewer-ci 31071252534 succeeded; the reviewer suite reports 370 passed, 1,497 statements and 492 branches at 100%, public docstrings at 100%, and zero unresolved threads.

Verify exact repository/base/head/patch binding, canonical UTF-8 patch metadata and hunk validation, governance-path refusal, descriptor-safe no-follow reads and inode stability, constant-space bounded Git status/tree output, alternate-object-database rejection, exact-tree/archive equality, Git blob rehashing for SHA-1/SHA-256, private staging, no-network/read-only/non-root Docker isolation, bounded result evidence, and complete credential separation. Submit actionable current-head findings or a substantive verdict. Do not infer branch-protection readiness or counted approval from status checks.

@coderabbitai

coderabbitai Bot commented Aug 6, 2026

Copy link
Copy Markdown

Tip

For best results, initiate chat on the files or code changes.

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
set -euo pipefail

repo="ContextualWisdomLab/noema"
pr="65"
base="9adb784902cae19a150146a8fadd6a0491f67814"
head="d29abd455759c1b8f3c4a5b04316395b4daff03f"

live_before="$(gh pr view "$pr" --repo "$repo" --json baseRefOid,headRefOid --jq '.baseRefOid + " " + .headRefOid')"
checked_out="$(git rev-parse HEAD)"
resolved_base="$(git rev-parse "${base}^{commit}")"
resolved_head="$(git rev-parse "${head}^{commit}")"
printf 'REVISION_BEFORE checked_out=%s resolved_base=%s resolved_head=%s live=%s\n' \
  "$checked_out" "$resolved_base" "$resolved_head" "$live_before"

printf '\n== Changed files ==\n'
git diff --name-status "$resolved_base" "$resolved_head"

printf '\n== Production structure ==\n'
ast-grep outline reviewer/noema_reviewer/patch_validation.py --items all --view signatures

printf '\n== Security-relevant definitions and contexts ==\n'
rg -n -C 6 \
  '^(def (_source_object_directory|_validated_exact_tree_record|_consume_exact_tree_stream|_validated_source_archive_members|_verify_git_blob_identity|_read|_run|inspect_patch_bytes|validate)|class )|alternates|http-alternates|git (status|ls-tree|archive)|O_NOFOLLOW|fstat|lstat|MAX_|MODE_METADATA_PATTERN|fullmatch|sha(1|256)|blob |--network|--read-only|--user=|cap-drop|no-new-privileges|--pull=never|result\.json|GIT_NO_' \
  reviewer/noema_reviewer/patch_validation.py

printf '\n== Exact tree, archive, blob, patch, result, and Docker sections ==\n'
for symbol in \
  _source_object_directory \
  _validated_exact_tree_record \
  _consume_exact_tree_stream \
  _validated_source_archive_members \
  _verify_git_blob_identity \
  inspect_patch_bytes \
  validate; do
  line="$(rg -n "^def ${symbol}\b" reviewer/noema_reviewer/patch_validation.py | head -1 | cut -d: -f1 || true)"
  if [ -n "$line" ]; then
    start=$((line > 12 ? line - 12 : 1))
    end=$((line + 230))
    printf '\n== %s: Lines %s-%s ==\n' "$symbol" "$start" "$end"
    sed -n "${start},${end}p" reviewer/noema_reviewer/patch_validation.py
  fi
done

printf '\n== Boundary tests ==\n'
for file in \
  reviewer/tests/test_patch_validation_exact_tree_archive_binding.py \
  reviewer/tests/test_patch_validation_object_alternates_boundary.py \
  reviewer/tests/test_patch_validation_blob_identity_edges.py \
  reviewer/tests/test_patch_validation_mode_boundaries.py \
  reviewer/tests/test_patch_validation_exact_tree_and_output.py; do
  if [ -f "$file" ]; then
    printf '\n== %s ==\n' "$file"
    cat -n "$file"
  fi
done

printf '\n== Public contract and workflow changes ==\n'
rg -n -C 5 \
  '(alternate object|alternates|http-alternates|exact.tree|exact tree|inventory|archive|Git blob|blob identity|SHA-1|SHA-256|rehash|object ID|object-id|Docker|result)' \
  docs/quarantined-patch-validation.md \
  docs/doctoring/quarantined-patch-validation.md \
  CHANGELOG.md
git diff --name-status "$resolved_base" "$resolved_head" -- .github/workflows
git diff -- "$resolved_base" "$resolved_head" -- .github/workflows
rg -n -i -C 2 \
  '(contents:\s*write|permissions:.*write|repair[-_ ]?pr|self[-_ ]?modif|git push|gh pr|COPILOT_GITHUB_TOKEN)' \
  .github 2>/dev/null || true

printf '\n== Checks and unresolved threads ==\n'
gh pr view "$pr" --repo "$repo" --json reviewDecision,statusCheckRollup \
  --jq '{reviewDecision, checks:[.statusCheckRollup[] | {name,status,conclusion,detailsUrl}]}'
gh api graphql -F owner='ContextualWisdomLab' -F name='noema' -F number="$pr" -f query='
query($owner: String!, $name: String!, $number: Int!) {
  repository(owner: $owner, name: $name) {
    pullRequest(number: $number) {
      reviewThreads(first: 100) {
        nodes {
          isResolved
          path
          line
          comments(first: 1) { nodes { author { login } body } }
        }
      }
    }
  }
}' --jq '.data.repository.pullRequest.reviewThreads.nodes[] | select(.isResolved == false)' || true

live_after="$(gh pr view "$pr" --repo "$repo" --json baseRefOid,headRefOid --jq '.baseRefOid + " " + .headRefOid')"
printf '\nREVISION_AFTER checked_out=%s live=%s\n' "$(git rev-parse HEAD)" "$live_after"

if [ "$checked_out" != "$resolved_head" ] ||
   [ "$live_before" != "$resolved_base $resolved_head" ] ||
   [ "$live_after" != "$resolved_base $resolved_head" ]; then
  echo 'EXACT_REVISION_MISMATCH_OR_CHANGED' >&2
  exit 2
fi

Length of output: 209957


@seonghobae I reviewed base 9adb784902cae19a150146a8fadd6a0491f67814 and head d29abd455759c1b8f3c4a5b04316395b4daff03f.

The base and head remained unchanged during the review.

I found one current actionable issue. I do not approve this PR.

P2 — Document the full exact-tree authentication boundary

reviewer/noema_reviewer/patch_validation.py implements these source-substitution controls:

  • _source_object_directory rejects source-local objects/info/alternates and objects/info/http-alternates.
  • _consume_exact_tree_stream retains a bounded inventory of canonical path, Git mode, object ID, and byte size.
  • _validated_source_archive_members requires the archive regular-file set, mode, and size to equal that inventory.
  • _verify_git_blob_identity reads each extracted file through a no-follow, inode-stable descriptor and verifies its Git blob <size>\0<bytes> SHA-1 or SHA-256 identity before Docker starts.

However, docs/quarantined-patch-validation.md Lines 64-72 and docs/doctoring/quarantined-patch-validation.md Lines 76-96 describe archive validation and archive-manifest-to-snapshot equality only.

Update both documents and the CHANGELOG.md Unreleased entry. State that:

  1. Source-local filesystem and HTTP alternate object databases are refused.
  2. Archive regular files must equal the authenticated exact-tree inventory by path, executable-derived Git mode, and size.
  3. Extracted regular-file bytes are descriptor-safely rehashed as Git blobs and must match the inventory SHA-1 or SHA-256 object ID.

The CI, reviewer, and security checks completed successfully. The skipped cancel-closed-pr-runs job is not success evidence. Check results do not replace an eligible independent approval or enforceable branch-protection evidence.

You are interacting with an AI system.

Copy link
Copy Markdown
Contributor Author

@coderabbitai review

Please perform a substantive review of exact current head d29abd455759c1b8f3c4a5b04316395b4daff03f. Treat draft-skip, rate-limit, temporary repair-workflow, and predecessor-head findings as stale unless they reproduce on this head. Focus on exact-tree streaming, immutable committed-source materialization, descriptor-safe blob/result reads, patch grammar and path-role binding, Docker credential/resource isolation, evidence identity, documentation accuracy, and the absence of write-capable repair workflows.

@opencode-agent @cwl-noema-review

Independent exact-head review is also requested for d29abd455759c1b8f3c4a5b04316395b4daff03f. Submit GitHub APPROVE only if this exact head satisfies repository policy, security boundaries, test and coverage gates, documentation, and every required check. A comment, model judgement, or commit status is not approval.

@coderabbitai

coderabbitai Bot commented Aug 6, 2026

Copy link
Copy Markdown

Your plan includes PR reviews subject to rate limits. More reviews will be available in 7 minutes.

Copy link
Copy Markdown
Contributor Author

@opencode-agent

Implement the valid exact-head CodeRabbit P2 documentation finding on current head d29abd455759c1b8f3c4a5b04316395b4daff03f; re-read the PR head immediately before any branch write and refuse or re-plan if it moved.

Update docs/quarantined-patch-validation.md, docs/doctoring/quarantined-patch-validation.md, and the CHANGELOG.md Unreleased entry so the authoritative contract explicitly states all four implemented source-substitution controls:

  1. source-local objects/info/alternates and objects/info/http-alternates are rejected rather than trusted;
  2. the bounded exact-tree inventory retains canonical path, Git mode, object ID, and byte size;
  3. the archive's complete regular-file set, executable-derived mode, and size must equal that authenticated exact-tree inventory; and
  4. each extracted regular file is read descriptor-safely and rehashed as blob <size>\0<bytes> using the repository's SHA-1 or SHA-256 object format before Docker starts, with exact object-ID equality required.

Keep the distinction among exact-tree authentication, archive allowlisting, post-extraction manifest equality, and Git blob identity verification precise. Do not claim the source object database itself is trusted beyond the explicitly documented residual-risk boundary. Preserve APA 7th citations, beginner-readable language, standalone/MSA compatibility, and the existing review-agent key contract. Do not add or restore any repair workflow, self-modifying Action, or workflow with branch-writing contents: write.

Run the documentation/format/link checks plus the full reviewer test, 100% production statement/branch coverage, and 100% public-docstring gates. After the new exact head exists, report the exact SHA and evidence; do not merge, enable auto-merge, resolve unrelated threads, or treat pending/queued checks as success.

Copy link
Copy Markdown
Contributor Author

@coderabbitai review

Please perform a substantive review of exact current head 5c2e6762d07598094e5301c491d15ba83dcdcd51 against base 9adb784902cae19a150146a8fadd6a0491f67814. Findings and review conclusions anchored to earlier heads are stale unless they remain reproducible here. The prior exact-head P2 documentation finding is addressed in docs/quarantined-patch-validation.md, docs/doctoring/quarantined-patch-validation.md, and CHANGELOG.md. Focus on source-local filesystem/HTTP alternate refusal, retained exact-tree path/mode/object-ID/size inventory, archive path/mode/size equality, descriptor-safe SHA-1/SHA-256 Git blob identity verification, bounded streaming, patch grammar, result-channel isolation, Docker isolation, and documentation accuracy. A successful commit status is not substantive review or approval.

@opencode-agent @cwl-noema-review

Independent review is requested for exact head 5c2e6762d07598094e5301c491d15ba83dcdcd51. ci run 31083752256, Security Scan run 31083752101, and reviewer-ci run 31083751990 completed successfully, and all inline threads are resolved. Submit GitHub APPROVE only if this exact head, enforceable repository policy, security boundaries, evidence separation, tests, documentation, and every required gate pass. Do not substitute a comment, commit status, or model judgement for approval.

@coderabbitai

coderabbitai Bot commented Aug 6, 2026

Copy link
Copy Markdown

Tip

For best results, initiate chat on the files or code changes.

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
set -euo pipefail

repo="ContextualWisdomLab/noema"
pr="65"
base="9adb784902cae19a150146a8fadd6a0491f67814"
head="5c2e6762d07598094e5301c491d15ba83dcdcd51"

live_before="$(gh pr view "$pr" --repo "$repo" --json baseRefOid,headRefOid --jq '.baseRefOid + " " + .headRefOid')"
checked_out="$(git rev-parse HEAD)"
resolved_base="$(git rev-parse "${base}^{commit}")"
resolved_head="$(git rev-parse "${head}^{commit}")"
printf 'REVISION_BEFORE checked_out=%s base=%s head=%s live=%s\n' \
  "$checked_out" "$resolved_base" "$resolved_head" "$live_before"

printf '\n== Changed files ==\n'
git diff --name-status "$resolved_base" "$resolved_head"
git diff --stat "$resolved_base" "$resolved_head"

printf '\n== Production structure ==\n'
ast-grep outline reviewer/noema_reviewer/patch_validation.py --items all --view signatures

printf '\n== Security-relevant definitions and contexts ==\n'
rg -n -C 6 \
  '^(def (_source_object_directory|_validated_exact_tree_record|_consume_exact_tree_stream|_validated_source_archive_members|_verify_git_blob_identity|_read|_run|inspect_patch_bytes|validate)|class )|alternates|http-alternates|git (status|ls-tree|archive)|O_NOFOLLOW|fstat|lstat|MAX_|MODE_METADATA_PATTERN|fullmatch|sha(1|256)|blob |--network|--read-only|--user=|cap-drop|no-new-privileges|--pull=never|result\.json|GIT_NO_' \
  reviewer/noema_reviewer/patch_validation.py

show_symbol() {
  local symbol="$1"
  local line
  line="$(rg -n "^def ${symbol}\b" reviewer/noema_reviewer/patch_validation.py | head -1 | cut -d: -f1 || true)"
  if [ -n "$line" ]; then
    local start=$((line > 15 ? line - 15 : 1))
    local end=$((line + 260))
    printf '\n== %s: Lines %s-%s ==\n' "$symbol" "$start" "$end"
    sed -n "${start},${end}p" reviewer/noema_reviewer/patch_validation.py
  fi
}

for symbol in \
  _source_object_directory \
  _validated_exact_tree_record \
  _consume_exact_tree_stream \
  _validated_source_archive_members \
  _verify_git_blob_identity \
  inspect_patch_bytes \
  validate; do
  show_symbol "$symbol"
done

printf '\n== Boundary regression tests ==\n'
for file in \
  reviewer/tests/test_patch_validation_exact_tree_archive_binding.py \
  reviewer/tests/test_patch_validation_object_alternates_boundary.py \
  reviewer/tests/test_patch_validation_blob_identity_edges.py \
  reviewer/tests/test_patch_validation_mode_boundaries.py \
  reviewer/tests/test_patch_validation_exact_tree_canonical_metadata.py \
  reviewer/tests/test_patch_validation_exact_tree_and_output.py; do
  if [ -f "$file" ]; then
    printf '\n== %s ==\n' "$file"
    cat -n "$file"
  fi
done

printf '\n== Exact diff for implementation, tests, and contract documents ==\n'
git diff --unified=30 "$resolved_base" "$resolved_head" -- \
  reviewer/noema_reviewer/patch_validation.py \
  reviewer/tests \
  docs/quarantined-patch-validation.md \
  docs/doctoring/quarantined-patch-validation.md \
  CHANGELOG.md

printf '\n== Documentation contract ==\n'
rg -n -C 5 \
  '(alternate object|alternates|http-alternates|exact.tree|exact tree|inventory|archive|Git blob|blob identity|SHA-1|SHA-256|rehash|object ID|object-id|Docker|result)' \
  docs/quarantined-patch-validation.md \
  docs/doctoring/quarantined-patch-validation.md \
  CHANGELOG.md

printf '\n== Workflow diff and privilege scan ==\n'
git diff --name-status "$resolved_base" "$resolved_head" -- .github/workflows
git diff -- "$resolved_base" "$resolved_head" -- .github/workflows
rg -n -i -C 2 \
  '(contents:\s*write|permissions:.*write|repair[-_ ]?pr|self[-_ ]?modif|git push|gh pr|COPILOT_GITHUB_TOKEN)' \
  .github 2>/dev/null || true

printf '\n== Checks, review decision, and unresolved threads ==\n'
gh pr view "$pr" --repo "$repo" --json reviewDecision,statusCheckRollup \
  --jq '{reviewDecision,checks:[.statusCheckRollup[]|{name,status,conclusion,detailsUrl}]}'
gh api graphql -F owner='ContextualWisdomLab' -F name='noema' -F number="$pr" -f query='
query($owner: String!, $name: String!, $number: Int!) {
  repository(owner: $owner, name: $name) {
    pullRequest(number: $number) {
      reviewThreads(first: 100) {
        nodes {
          isResolved
          path
          line
          comments(first: 1) { nodes { author { login } body } }
        }
      }
    }
  }
}' --jq '.data.repository.pullRequest.reviewThreads.nodes[] | select(.isResolved == false)' || true

live_after="$(gh pr view "$pr" --repo "$repo" --json baseRefOid,headRefOid --jq '.baseRefOid + " " + .headRefOid')"
printf '\nREVISION_AFTER checked_out=%s live=%s\n' "$(git rev-parse HEAD)" "$live_after"

if [ "$checked_out" != "$resolved_head" ] ||
   [ "$live_before" != "$resolved_base $resolved_head" ] ||
   [ "$live_after" != "$resolved_base $resolved_head" ]; then
  echo 'EXACT_REVISION_MISMATCH_OR_CHANGED' >&2
  exit 2
fi

Length of output: 144563


🏁 Script executed:

#!/bin/bash
set -euo pipefail

repo="ContextualWisdomLab/noema"
pr="65"
base="9adb784902cae19a150146a8fadd6a0491f67814"
head="5c2e6762d07598094e5301c491d15ba83dcdcd51"

before="$(gh pr view "$pr" --repo "$repo" --json baseRefOid,headRefOid --jq '.baseRefOid + " " + .headRefOid')"
test "$(git rev-parse HEAD)" = "$head"
test "$before" = "$base $head"

file="reviewer/noema_reviewer/patch_validation.py"

show_function() {
  local symbol="$1"
  local line
  line="$(rg -n "^def ${symbol}\b" "$file" | head -1 | cut -d: -f1)"
  printf '\n== %s (Line %s) ==\n' "$symbol" "$line"
  nl -ba "$file" | sed -n "$((line > 10 ? line - 10 : 1)),$((line + 300))p"
}

printf '== Relevant constants, models, and helper definitions ==\n'
rg -n -C 4 \
  '^(MAX_|TRUSTED_|PATCH_SANDBOX_|class (PatchValidation|ExactTree)|def (_read_regular|_read_result_payload|_verify_source_head|_verify_exact_tree_limits|_materialize_committed_source|_extract|_validated_source_archive_members|_verify_git_blob_identity|_docker|_source_object_directory))' \
  "$file"

for symbol in \
  _source_object_directory \
  _verify_source_head \
  _validated_exact_tree_record \
  _consume_exact_tree_stream \
  _materialize_committed_source \
  _validated_source_archive_members \
  _verify_git_blob_identity \
  _read_result_payload \
  validate; do
  show_function "$symbol"
done

printf '\n== Exact-tree/archive/blob regression test names and assertions ==\n'
for file in \
  reviewer/tests/test_patch_validation_exact_tree_archive_binding.py \
  reviewer/tests/test_patch_validation_blob_identity_edges.py \
  reviewer/tests/test_patch_validation_object_alternates_boundary.py; do
  printf '\n== %s ==\n' "$file"
  rg -n -C 4 '^def test_|assert |pytest\.raises' "$file"
done

printf '\n== Workflow changes introduced by this PR ==\n'
git diff --name-status "$base" "$head" -- .github/workflows
git diff --unified=5 "$base" "$head" -- .github/workflows

after="$(gh pr view "$pr" --repo "$repo" --json baseRefOid,headRefOid --jq '.baseRefOid + " " + .headRefOid')"
printf '\nREVISION_AFTER checked_out=%s live=%s\n' "$(git rev-parse HEAD)" "$after"
test "$(git rev-parse HEAD)" = "$head"
test "$after" = "$base $head"

Length of output: 7547


🏁 Script executed:

#!/bin/bash
set -euo pipefail

repo="ContextualWisdomLab/noema"
pr="65"
base="9adb784902cae19a150146a8fadd6a0491f67814"
head="5c2e6762d07598094e5301c491d15ba83dcdcd51"

before="$(gh pr view "$pr" --repo "$repo" --json baseRefOid,headRefOid --jq '.baseRefOid + " " + .headRefOid')"
test "$(git rev-parse HEAD)" = "$head"
test "$before" = "$base $head"

file="reviewer/noema_reviewer/patch_validation.py"

show_function() {
  local symbol="$1"
  local line
  line="$(rg -n "^def ${symbol}\b" "$file" | head -1 | cut -d: -f1)"
  printf '\n== %s (Line %s) ==\n' "$symbol" "$line"
  cat -n "$file" | sed -n "$((line > 10 ? line - 10 : 1)),$((line + 260))p"
}

for symbol in \
  _source_object_directory \
  _verify_source_head \
  _validated_exact_tree_record \
  _consume_exact_tree_stream \
  _materialize_committed_source \
  _validated_source_archive_members \
  _verify_git_blob_identity \
  _read_result_payload \
  validate; do
  show_function "$symbol"
done

printf '\n== Exact-tree/archive/blob regression assertions ==\n'
for test_file in \
  reviewer/tests/test_patch_validation_exact_tree_archive_binding.py \
  reviewer/tests/test_patch_validation_blob_identity_edges.py \
  reviewer/tests/test_patch_validation_object_alternates_boundary.py; do
  printf '\n== %s ==\n' "$test_file"
  rg -n -C 4 '^def test_|assert |pytest\.raises' "$test_file"
done

printf '\n== Workflow files changed by this PR ==\n'
git diff --name-status "$base" "$head" -- .github/workflows

after="$(gh pr view "$pr" --repo "$repo" --json baseRefOid,headRefOid --jq '.baseRefOid + " " + .headRefOid')"
printf '\nREVISION_AFTER checked_out=%s live=%s\n' "$(git rev-parse HEAD)" "$after"
test "$(git rev-parse HEAD)" = "$head"
test "$after" = "$base $head"

Length of output: 99288


🏁 Script executed:

#!/bin/bash
set -euo pipefail

repo="ContextualWisdomLab/noema"
pr="65"
base="9adb784902cae19a150146a8fadd6a0491f67814"
head="5c2e6762d07598094e5301c491d15ba83dcdcd51"

printf 'checked_out=%s\n' "$(git rev-parse HEAD)"
gh pr view "$pr" --repo "$repo" --json baseRefOid,headRefOid \
  --jq '{baseRefOid,headRefOid}'

test "$(git rev-parse HEAD)" = "$head"
test "$(gh pr view "$pr" --repo "$repo" --json baseRefOid --jq '.baseRefOid')" = "$base"
test "$(gh pr view "$pr" --repo "$repo" --json headRefOid --jq '.headRefOid')" = "$head"

Length of output: 838


@seonghobae I completed a read-only review of base 9adb784902cae19a150146a8fadd6a0491f67814 and head 5c2e6762d07598094e5301c491d15ba83dcdcd51.

The base and head remained unchanged during the review.

I found no actionable current-head issue in the requested scope.

The previous P2 documentation finding is addressed. The public document, doctoring record, and CHANGELOG.md now describe:

  • rejection of source-local objects/info/alternates and objects/info/http-alternates;
  • bounded exact-tree inventory retention for canonical path, Git mode, object ID, and byte size;
  • exact archive regular-file path, mode, size, and file-set equality;
  • descriptor-safe SHA-1 or SHA-256 Git blob identity verification before Docker starts.

The reviewed implementation matches that contract. It also retains bounded Git output handling, strict patch metadata and path checks, single-file result evidence, exact request/result binding, private patch staging, and no-network, read-only, non-root Docker restrictions.

The successful CI, reviewer, and security checks are supporting evidence. The skipped cancel-closed-pr-runs job is not success evidence.

I do not issue formal approval. The available review evidence does not establish enforceable branch protection or an eligible independent approval.

You are interacting with an AI system.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants